<template>
  <div class="model-item">
    <div class="model-item-header">热门推荐</div>
    <div class="img-box" v-for="(item,key) in datas" :key="key">
      <img :src="global.serviceUrl + item.src|defaultImg" alt="暂无图片">
      <div class="model-over">
        <div class="model-info-box">
          <p class="model-info">{{ item.title }}</p>
          <span class="model-btn" @click="readIt(item.id)">阅读</span>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "ModelItem",
  props: ["datas"],
  methods: {
    // 跳转文章
    readIt(id) {
      this.$router.push({
        path: "/info",
        query: {
          id: id
        }
      });
    }
  },
  filters:{
    defaultImg(val){
      if (val) {
        return val;
      } else {
        return 'static/default/default.png';
      }
    }
  }
};
</script>
<style scoped>
/* 特别推荐 */
.model-item-header {
  font-size: 18px;
  height: 36px;
  line-height: 36px;
  font-weight: bold;
  border-bottom: 2px solid;
}
.img-box > img {
  height: auto;
  width: 100%;
  display: block;
}
.img-box {
  height: auto;
  margin-top: 10px;
  position: relative;
}
.model-over {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
}
.model-info-box {
  text-align: center;
}
.model-info {
  font-size: 16px;
  padding: 10px 20px;
}
.model-btn {
  display: inline-block;
  border: 1px solid #fff;
  padding: 5px 20px;
  border-radius: 20px;
  cursor: pointer;
}
.model-btn:hover {
  color: #2db7f5;
  border: 1px solid#2db7f5;
}
</style>


